<?php /* narato/vivasky */

   $narato_options = get_option('narato');
   $font_styles = font_styles();
   header('Content-type: text/css');
   header("Expires: Mon, 25 Dec 1989 02:00:00 GMT");
   header("Cache-Control: no-cache");
   header("Pragma: no-cache");

   echo '@import "'.THEME_URL.'/color-'.$narato_options['color_scheme'].'.css";'.PHP_EOL;
   do_action('narato_css');

   // font styles
   if($narato_options['font_style'] != 0)
    echo '*{font-family:'.$font_styles[$narato_options['font_style']]['code'].';}'.PHP_EOL;

   // column dimensions
   $w = $narato_options['page_width'];
   $unit = ($w == 'fluid') ? '%' : 'px';
   $gs = ($w == 'fluid') ? '100' : '980';
   $gutter=($w == 'fluid') ? 5:20;
   switch ($narato_options['layout']):
    case 'g-col2-mr':
      $s = explode(";", $narato_options['dimensions'][$w]['g-col2-mr']);
      echo 'body.'.$w.'.g-col2-mr #main{margin-left:'.($s[0]).$unit.';}'.PHP_EOL;
      echo 'body.'.$w.'.g-col2-mr #aside-x{width:'.($s[0]-$gutter).$unit.';}'.PHP_EOL;
      break;
    case 'g-col2-ml':
      $s = explode(";", $narato_options['dimensions'][$w]['g-col2-ml']);
      echo 'body.'.$w.'.g-col2-ml #main{margin-right:'.($gs-$s[0]).$unit.';}'.PHP_EOL;
      echo 'body.'.$w.'.g-col2-ml #aside-x{width:'.($gs-$s[0]-$gutter).$unit.';}'.PHP_EOL;
      break;
    case 'g-col3-mm':
      $s = explode(";", $narato_options['dimensions'][$w]['g-col3-mm']);
      echo 'body.'.$w.'.g-col3-mm #main .col-m-inner{margin-left:'.($gs-$s[1]-$gutter/2).$unit.';margin-right:'.($s[0]+$gutter/2).$unit.';}'.PHP_EOL;
      echo 'body.'.$w.'.g-col3-mm #aside-x{width:'.($gs-$s[1]).$unit.';}'.PHP_EOL;
      echo 'body.'.$w.'.g-col3-mm #aside-y{width:'.$s[0].$unit.';margin-left:'.(-($gs-$s[1])).$unit.';}'.PHP_EOL;
      break;
    case 'g-col3-mr':
      $s = explode(";", $narato_options['dimensions'][$w]['g-col3-mr']);
      echo 'body.'.$w.'.g-col3-mr #main{margin-left:'.$s[1].$unit.';}'.PHP_EOL;
      echo 'body.'.$w.'.g-col3-mr #aside-x{width:'.$s[0].$unit.';}'.PHP_EOL;
      echo 'body.'.$w.'.g-col3-mr #aside-y{width:'.($s[1]-$s[0]-$gutter).$unit.';margin-left:'.($gutter/2).$unit.';}'.PHP_EOL;
      break;
    case 'g-col3-ml':
      $s = explode(";", $narato_options['dimensions'][$w]['g-col3-ml']);
      echo 'body.'.$w.'.g-col3-ml #main{margin-right:'.($gs-$s[0]).$unit.';}'.PHP_EOL;
      echo 'body.'.$w.'.g-col3-ml #aside-x{width:'.($gs-$s[1]).$unit.';}'.PHP_EOL;
      echo 'body.'.$w.'.g-col3-ml #aside-y{width:'.($s[1]-$s[0]-$gutter).$unit.';margin-right:'.($gutter/2).$unit.';}'.PHP_EOL;
      break;
   endswitch;

   if($narato_options['background']) echo '#page{background-image:none;}'.PHP_EOL.'body{background-image:url("'.$narato_options['background'].'");background-repeat:no-repeat;background-position:center top;}'.PHP_EOL;
   if(($narato_options['background_color']) && (strpos($narato_options['background_color'],'000000') === false)):
    echo 'body{background-color:#'.$narato_options['background_color'].';}'.PHP_EOL;
    if (!$narato_options['background']) echo 'body,#page{background-image:none;}'.PHP_EOL;
   endif;

   $thumb_size = explode('x',get_narato_option('post_thumb'));
   echo '.post-info.with-thumbs{margin-left:'.($thumb_size[0]+30).'px;}'.PHP_EOL;

   if($narato_options['user_css']) echo $narato_options['user_css'].PHP_EOL;
   if (is_single() || is_page()):
     global $post;
     $css = get_post_meta($post->ID, 'css', true);
     if (!empty($css)) echo $css.PHP_EOL;
   endif;
?>